package com.maschinenstuermer.profiler.model.impl;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class SqlStatementExecution extends Invocation {
	@XmlAttribute(required=true)
	private String className;

	@XmlAttribute(required=true)
	private String statement;

	/**
	 * Required by JAXB.
	 */
	public SqlStatementExecution() {	
	}
	
	public SqlStatementExecution(String className, String statement) {
		this.className = className;
		this.statement = statement;
	}

	public String getStatement() {
		return statement;
	}

	public String getClassName() {
		return className;
	}

	@Override
	public void accept(ModelVisitor visitor) {
		visitor.visit(this);
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result
				+ ((className == null) ? 0 : className.hashCode());
		result = prime * result
				+ ((statement == null) ? 0 : statement.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		SqlStatementExecution other = (SqlStatementExecution) obj;
		if (className == null) {
			if (other.className != null)
				return false;
		} else if (!className.equals(other.className))
			return false;
		if (statement == null) {
			if (other.statement != null)
				return false;
		} else if (!statement.equals(other.statement))
			return false;
		return true;
	}

}
